home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 34 / Mac Magazin and MacEasy Magazine CD - Issue 34.iso / Grafik & Text / Alpha ƒ / Tcl / Modes / applescriptMode.tcl < prev    next >
Text File  |  1996-08-15  |  3KB  |  85 lines

  1. #############################################################################
  2. # AppleScript.tcl
  3. #  John Sarapata
  4. #  sarapata_john@jpmorgan.com
  5. #
  6. # Installing:
  7. #    Put AppleScript.tcl in your Usercode folder
  8. #   Put the following line in userstartup.tcl:
  9. #     source $HOME:Tcl:Usercode:AppleScript.tcl
  10. #
  11. # Description:
  12. #    This file implements an AppleScript mode, for people who wish Script
  13. #    Editor had complex functions like search and replace. Currently, it
  14. #    only supports color editing and function finding, but I may extend it.
  15. #
  16. #    I have not found a way to distinguish function definitions from
  17. #    on error constructs, so I assume that any "on name" statements at
  18. #    the beginning of the line are definitions. Script Editor saves files
  19. #    in this format, so you will only need to be careful when creating
  20. #    functions in Alpha.
  21. #############################################################################
  22.  
  23. if {$startingUp} {
  24.     addMode Scrp dummyScrp {*.script} { }
  25.  
  26.     return
  27. }
  28.  
  29.  
  30. #===============================================================================
  31. #    Set up the mode variables
  32. newModeVar    Scrp     elecRBrace            {0}    1
  33. newModeVar    Scrp     electricSemi        {0}    1
  34. newModeVar    Scrp    elecLBrace            {0} 1
  35. newModeVar    Scrp    electricTab            {0} 1
  36. newModeVar    Scrp    wordWrap            {0} 1
  37. newModeVar    Scrp    autoMark            {0}    1
  38. newModeVar    Scrp    prefixString        {--} 0
  39. newModeVar    Scrp    leftFillColumn         {3} 0
  40. newModeVar    Scrp    funcExpr            {^(ON)[ \t]+(\w+)} 0
  41. newModeVar    Scrp    wordBreak             {\w+} 0
  42. newModeVar    Scrp    wordBreakPreface     {\W} 0
  43.  
  44. proc dummyScrp {} {}
  45.  
  46. #===============================================================================
  47. #    Set up comments and keywords
  48. set scriptKeyWords {
  49.     on end error global local return it me pi result space tab
  50.     close copy count data size delete duplicate exists get launch
  51.     make move open print quit run save in of is after before
  52.     div mod and not or start starts begin begins end ends contains
  53.     does equal equals greater less than as reference
  54.     set try
  55.     tell if repeat else then times while until with by
  56.     considering ignoring timeout transaction script property prop
  57.     first second third fourth fifth sixth seventh eighth ninth tenth
  58.     last front back middle every some from to through thru
  59. }
  60.  
  61. regModeKeywords -e {--} -b {\(*} {*\)} -c red -k blue Scrp $scriptKeyWords
  62.  
  63. unset scriptKeyWords
  64.  
  65. #===============================================================================
  66. #    File Marking
  67. proc ScrpMarkFile {} {
  68.     global ScrpmodeVars
  69.     set pos 0
  70.     while {![catch {search -f 1 -r 1 -m 0 -i 1 $ScrpmodeVars(funcExpr) $pos} res]} {
  71.         set start [lindex $res 0]
  72.         set end [lindex $res 1]
  73.         set text [lindex [getText $start $end] 1]
  74.         set pos $end
  75.         set inds($text) "$start $end"
  76.     }
  77.     
  78.     if {[info exists inds]} {
  79.         foreach f [lsort [array names inds]] {
  80.             setNamedMark $f [lineStart [lineStart [lindex $inds($f) 0]] - 1] [lindex $inds($f) 0] [lindex $inds($f) 1]
  81.         }
  82.     }
  83. }
  84.  
  85.